Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Implemented resolving of relative module names to absolute paths #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ichernev
Copy link

Specifying files to mock by a relative name is not enough if you require the same file multiple times from different directories. So I added an option to mockery to convert all relative filenames to absolute ones, based on the test file for example. There are two advantages of doing so:

  1. You can specify the filenames to mock, relative to the test file -- i.e the same way requires work, so its a no-brainer
  2. Requiring the same file from multiple locations would return the given mock, because all filenames are converted to absolute ones when requiring

@benbuckman
Copy link

+1

@benbuckman
Copy link

I wonder, couldn't this be done more simply, with path.resolve or require.resolve on all entries to registeredMocks? (Probably as an option in registerMock)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants